<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initSessions()
	{
		Zend_Session::start();
	}
	
	/**
	 *
	 * Initiate the database connection and register in the variable $db for
	 * utilize that when it convenients.
	 *
	 * @access protected
	 * @return null
	 */
	protected function _initConnection()
	{
		$options    = $this->getOption('resources');
		$db_adapter = $options['db']['adapter'];
		$params     = $options['db']['params'];
		try
		{
			$db = Zend_Db::factory($db_adapter, $params);
			$db->getConnection();
			$registry = Zend_Registry::getInstance();
			$registry->set('db', $db);
		}
		catch( Zend_Exception $e)
		{
			echo "ERRO na conexao com o banco";
			exit;
		}
	}
	
	protected function _initAutoload()
	{
		require_once 'Zend/Loader/Autoloader.php';
		$moduleLoader = new Zend_Application_Module_Autoloader(array(
				'basePath'      => APPLICATION_PATH,
				'namespace'     => 'Application' ));
		$autoloader = Zend_Loader_Autoloader::getInstance();
		$autoloader->setFallbackAutoloader(true);
		return $autoloader;
	}
	
	
	protected function _initDoctype()
	{
		$this->bootstrap('View');
		$view = $this->getResource('View');
		
		$view->logado = true;
		//Bootstrap -->
		
		$view->headLink()->appendStylesheet('/css/bootstrap.css','all');
		$view->headLink()->appendStylesheet('/css/bootstrap-responsive.min.css','all');
		
		$view->headScript()->appendFile('//code.jquery.com/jquery.js');
		$view->headScript()->appendFile('/js/bootstrap.min.js');
		$view->headScript()->appendFile('/js/bootbox.min.js');
	
	}
	
	protected function _initAcl()
	{
		$aclSetup = new Application_Acl_Setup();
	}

}